package view;
import java.awt.Component;
import java.awt.Graphics;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JComponent;
import javax.swing.JLabel;
import controller.DragNDrop;

import javax.swing.border.*;


/**
 * 
 */

/**
 * @author Leo COLLET, Nelle VAROQUAUX
 *
 */
public class Wardrobe extends JPanel implements Icon, MouseListener{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static JLabel icone ;
	Border thickBorder = new LineBorder(Color.DARK_GRAY, 1);
	Border thickBorder_hover = new LineBorder(Color.DARK_GRAY, 2);

	public Wardrobe(){
	    super();
	    this.build();
	}

	private void build(){
	    this.setBounds(774, 10, 70, 50);
	    this.setBackground(Color.LIGHT_GRAY);
	    this.setBorder(thickBorder);
	    ImageIcon iconimage = createImageIcon("../icons/wardrobe.png", "a pretty but meaningless splat");
	    icone = new JLabel(iconimage);
	    this.add(icone);
	    addMouseListener(this);
	    this.setVisible(true);
	}


	/* (non-Javadoc)
	 * @see javax.swing.Icon#getIconHeight()
	 */
	@Override
	public int getIconHeight() {
		// TODO Auto-generated method stub
		return 0;
	}

	/* (non-Javadoc)
	 * @see javax.swing.Icon#getIconWidth()
	 */
	@Override
	public int getIconWidth() {
		// TODO Auto-generated method stub
		return 0;
	}

	/* (non-Javadoc)
	 * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, int, int)
	 */
	@Override
	public void paintIcon(Component c, Graphics g, int x, int y) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseEntered(MouseEvent e){
	    DragNDrop dnd = DragNDrop.getInstance();
	    this.setBorder(thickBorder_hover);
	    dnd.addTarget(this);
	}

	@Override
	public void mouseExited(MouseEvent e){
	    DragNDrop dnd = DragNDrop.getInstance();
	    dnd.removeTarget(this);
	    this.setBorder(thickBorder);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
	    System.out.println("User clicked on Wardrobe");	
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		System.out.println("User pressed on Wardrobe");	

	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		DragNDrop dnd = DragNDrop.getInstance();
		dnd.addTarget(this);
		JComponent source = dnd.getSource();
		System.out.println("User released" + source +" on Wardrobe");	

	}

	protected ImageIcon createImageIcon(String path, String description) {
		java.net.URL imgURL = getClass().getResource(path);
		if (imgURL != null) {
			return new ImageIcon(imgURL, description);
		} else {
			System.err.println("Couldn't find file: " + path);
			return null;
		}
	}
}
